<template>
  <div class="profile">
    <h3>学生信息</h3>
    <ul>
      <li> id: {{ student.id }} </li>
      <li> name: {{ student.name }} </li>
      <li> account: {{ student.account }} </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'ProfileView',
  data(){
    return {
      student: {
        id: '',
        name: '',
        account: ''
      }
    }
  },
  created(){
    // 尝试从 sessionStorage 中获取已登录学生信息
    let str = sessionStorage.getItem('LOGGED_IN_STUDENT');
    // 将在 sessionStorage 存储的 字符串 解析为 JavaScript 对象
    let stu = JSON.parse( str );
    console.log( stu );
    this.student.id = stu.id ;
    this.student.name = stu.name ;
    this.student.account = stu.account ;
  }
}
</script>

<style>

</style>